package org.papillion39.sechelper.application.business.model;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.time.LocalDate;

/**
 *
 * @author Jonathan Paz <jonathan.paz@ottr.com>
 */
public class Member implements Serializable {
    private int id;
    private String firstName;
    private String middleName;
    private String lastName;
    private LocalDate dateOfBirth;
    private LocalDate dateOfDeath;
    private String emailAddress;
    private boolean preferEmail;
    private Address[] address;
    private final PropertyChangeSupport support = new PropertyChangeSupport(this);

    public Member() {
    }

    public Member(int id, String firstName, String middleName, String lastName, LocalDate dateOfBirth, LocalDate dateOfDeath, String emailAddress, boolean preferEmail, Address[] address) {
        this.id = id;
        this.firstName = firstName;
        this.middleName = middleName;
        this.lastName = lastName;
        this.dateOfBirth = dateOfBirth;
        this.dateOfDeath = dateOfDeath;
        this.emailAddress = emailAddress;
        this.preferEmail = preferEmail;
        this.address = address;
    }

    public int getId() {
        return id;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        String oldfirstName = this.firstName;
        this.firstName = firstName;
        support.firePropertyChange("firstName", oldfirstName, firstName);
    }

    public String getMiddleName() {
        return middleName;
    }

    public void setMiddleName(String middleName) {
        String oldmiddleName = this.middleName;
        this.middleName = middleName;
        support.firePropertyChange("middleName", oldmiddleName, middleName);
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        String oldlastName = this.lastName;
        this.lastName = lastName;
        support.firePropertyChange("lastName", oldlastName, lastName);
    }

    public LocalDate getDateOfBirth() {
        return dateOfBirth;
    }

    public void setDateOfBirth(LocalDate dateOfBirth) {
        LocalDate olddateOfBirth = this.dateOfBirth;
        this.dateOfBirth = dateOfBirth;
        support.firePropertyChange("dateOfBirth", olddateOfBirth, dateOfBirth);
    }

    public LocalDate getDateOfDeath() {
        return dateOfDeath;
    }

    public void setDateOfDeath(LocalDate dateOfDeath) {
        LocalDate olddateOfDeath = this.dateOfDeath;
        this.dateOfDeath = dateOfDeath;
        support.firePropertyChange("dateOfDeath", olddateOfDeath, dateOfDeath);
    }

    public String getEmailAddress() {
        return emailAddress;
    }

    public void setEmailAddress(String emailAddress) {
        String oldemailAddress = this.emailAddress;
        this.emailAddress = emailAddress;
        support.firePropertyChange("emailAddress", oldemailAddress, emailAddress);
    }

    public boolean isPreferEmail() {
        return preferEmail;
    }

    public void setPreferEmail(boolean preferEmail) {
        boolean oldpreferEmail = this.preferEmail;
        this.preferEmail = preferEmail;
        support.firePropertyChange("preferEmail", oldpreferEmail, preferEmail);
    }

    public Address[] getAddress() {
        return address;
    }

    public void setAddress(Address[] address) {
        Address[] oldaddress = this.address;
        this.address = address;
        support.firePropertyChange("address", oldaddress, address);
    }

    public Address getAddress(int index) {
        return address[index];
    }

    public void setAddress(int index, Address address) {
        Address oldaddress = this.address[index];
        this.address[index] = address;
        support.fireIndexedPropertyChange("address", index, oldaddress, address);
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        support.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        support.removePropertyChangeListener(listener);
    }

    public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        support.addPropertyChangeListener(propertyName, listener);
    }

    public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
        support.removePropertyChangeListener(propertyName, listener);
    }
}
